package com.yxx.mapper;

import com.yxx.medicinepojo.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * @author yuxiangxun
 * @date 2024/9/23
 * @apiNote
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * 查看购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> ShowShoppingCartList(ShoppingCart shoppingCart);

    /**
     * 通过id修改当前某个购物车的单一数据（number = number+1）
     * @param cart
     */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumberById(ShoppingCart cart);

    /**
     * 添加购物车信息
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart(name,user_id,medicine_id,setmedicine_id,number,amount,image,create_time)" +
            "values (#{name},#{userId},#{chinesewesternmedicineId},#{setmedicineId},#{number},#{amount},#{image},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    /**
     * 通过shoppingCartById删除一整条购物车记录
     * @param shoppingCartById
     */
    @Delete("delete from shopping_cart where id = #{shoppingCartById}")
    void deleteShoppingCartById(Long shoppingCartById);

    /**
     * 根据微信用户id清空购物车数据
     * @param wxUserId
     */
    @Delete("delete from shopping_cart where user_id = #{wxUserId}")
    void deleteShoppingCartByUserId(Long wxUserId);

    /**
     * 批量插入购物车数据
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);

}
